package dshop.model.push;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import appbase.jfinal.ext.BaseModel;
import appbase.jfinal.ext.ModelKit;

public class PushUser extends BaseModel<PushUser> {

	private static final long serialVersionUID = -6967680902549117464L;

	public static final PushUser dao = new PushUser();

	public static PushUser create(int pushRecordId, int userId, int tagId) {
		PushUser pushUser = new PushUser();
		pushUser.set("pushRecordId", pushRecordId).set("userId", userId).set("tagId", tagId).set("createTime",
				new Date());
		return pushUser;
	}

	public static List<Integer> listUserIdBy(List<Integer> pushRecordIdList) {
		if (pushRecordIdList == null || pushRecordIdList.isEmpty()) {
			return new ArrayList<Integer>();
		}

		String sql = " select distinct userId from push_user where pushRecordId in (??)";
		sql = dao.buildSqlHasIn(sql, pushRecordIdList);
		List<PushUser> userList = dao.find(sql);
		return ModelKit.getToList(userList, "userId", Integer.class);
	}

}
